﻿using IterationLife.Datas;
using IterationLife.Educations.Models;
using IterationLife.Educations.Queries;
using IterationLife.Educations.Repositories;
using IterationLife.PlatformBackEnd.AppServices.Contracts.Educations;
using IterationLife.PlatformBackEnd.AppServices.Dtos.Educations;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.PlatformBackEnd.AppServices.Impl.Educations {
    /// <summary>
    /// 用户能力服务
    /// </summary>
    public class UserAbilityService : ApplicationServiceBase<UserAbility, UserAbilityDto, UserAbilityQuery>, IUserAbilityService {
        /// <summary>
        /// 初始化用户能力服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="userAbilityRepository">用户能力仓储</param>
        public UserAbilityService( IApplicationUnitOfWork unitOfWork, IUserAbilityRepository userAbilityRepository )
            : base( unitOfWork, userAbilityRepository ) {
            UserAbilityRepository = userAbilityRepository;
        }
        
        /// <summary>
        /// 用户能力仓储
        /// </summary>
        protected IUserAbilityRepository UserAbilityRepository { get; set; }
        
        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override UserAbilityDto ToDto( UserAbility entity ) {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override UserAbility ToEntity( UserAbilityDto dto ) {
            return dto.ToEntity();
        }
        
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">用户能力查询实体</param>
        protected override IQueryBase<UserAbility> CreateQuery( UserAbilityQuery param ) {
            return new Query<UserAbility>( param );
        }
    }
}